package com.icebartech.core.utils;

import java.lang.reflect.InvocationTargetException;
import java.util.Locale;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;

/**
 * 对象拷贝工具类，此封装能支持date等类型的转换
 * @author wenhsh
 *
 */
public class ExtBeanUtils extends BeanUtils {
    static {
        // 设定地区后会启用Str转Date 不需要自己重新实现Converter
        DateConverter utilDateConverter = new DateConverter(null);
        utilDateConverter.setLocale(Locale.CHINA);
        ConvertUtils.register(utilDateConverter, java.util.Date.class);
    }
    
    public static void copyProperties(Object dest, Object orig) throws InvocationTargetException, IllegalAccessException {
        if (dest == orig) return;
        BeanUtils.copyProperties(dest, orig);
    }


}